// 模拟登录接口
export const loginAPI = (credentials) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if (credentials.username === 'admin' && credentials.password === '123456') {
        resolve({
          data: {
            token: 'mock-token-admin',
            userInfo: {
              id: 1,
              username: 'admin',
              role: 'admin',
              permissions: ['*']
            }
          }
        })
      } else {
        reject(new Error('用户名或密码错误'))
      }
    }, 800) // 模拟网络延迟
  })
}

// 模拟获取用户信息
export const getUserInfoAPI = () => {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({
        data: {
          id: 1,
          username: 'admin',
          avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
          roles: ['admin'],
          permissions: ['*']
        }
      })
    }, 300)
  })
} 